<!DOCTYPE html>
<html class="ui-page-login">

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<link href="../css/mui.min.css" rel="stylesheet" />
		<link href="../css/login.css" rel="stylesheet" />
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">用户登录</h1>
		</header>
		<div class="mui-content">
			<form id='login-form' class="mui-input-group">
				<div class="mui-input-row">
					<label>账号</label>
					<input id='account' type="text" class="mui-input-clear mui-input" placeholder="请输入账号">
				</div>
				<div class="mui-input-row">
					<label>密码</label>
					<input id='password' type="password" class="mui-input-clear mui-input" placeholder="请输入密码">
				</div>
			</form>
			<div class="mui-content-padded">
				<button id='login' class="mui-btn mui-btn-block mui-btn-primary">登录</button>
				<div class="link-area">
					<a id='register'>注册账号</a> <span class="spliter">|</span>
					<a id='forgetPassword'>忘记密码</a>
				</div>
			</div>
			<div class="mui-content-padded oauth-area">

			</div>
		</div>
		<script src="../js/mui.min.js"></script>
		<script src="../js/mui.enterfocus.js"></script>
		<script type="text/javascript" src="../js/const.js"></script>
		<script type="text/javascript" src="../js/request.js"></script>
		<script type="text/javascript" src="../js/user_service.js"></script>
		<script src="../js/app.js"></script>
		<script>
			mui.init({
				statusBarBackground: '#f7f7f7',
				//				beforeback: function() {
				//					//获得列表界面的webview  
				//					var list = plus.webview.currentWebview().opener();
				//					//触发列表界面的自定义事件（refresh）,从而进行数据刷新  
				//					mui.fire(list, 'refresh');
				//					//返回true，继续页面关闭逻辑  
				//					return true;
				//				}

			});

			(function($, doc) {

				$.plusReady(function() {
					plus.screen.lockOrientation("portrait-primary");
					var settings = app.getSettings();
					var state = app.getState();
					var main_loaded_flag = false;
					// close splash
					setTimeout(function() {
						//关闭 splash
						plus.navigator.closeSplashscreen();
					}, 600);
					//检查 "登录状态/锁屏状态" 结束
					var loginButton = doc.getElementById('login');
					var accountBox = doc.getElementById('account');
					var passwordBox = doc.getElementById('password');
					var regButton = doc.getElementById('register');
					var forgetButton = doc.getElementById('forgetPassword');
					loginButton.addEventListener('tap', function(event) {
						var loginInfo = {
							account: accountBox.value,
							password: passwordBox.value
						};
						
						app.login(loginInfo);
					
					});
					$.enterfocus('#login-form input', function() {
						$.trigger(loginButton, 'tap');
					});
					regButton.addEventListener('tap', function(event) {
						$.openWindow({
							url: 'register.html',
							id: 'register',
							preload: true,
							show: {
								aniShow: 'pop-in'
							},
							styles: {
								popGesture: 'hide'
							},
							waiting: {
								autoShow: false
							}
						});
					}, false);
					forgetButton.addEventListener('tap', function(event) {
						$.openWindow({
							url: 'forget_password.html',
							id: 'forget_password',
							preload: true,
							show: {
								aniShow: 'pop-in'
							},
							styles: {
								popGesture: 'hide'
							},
							waiting: {
								autoShow: false
							}
						});
					}, false);

					//						var back = mui.back();
					//						mui.back = function(){
					//						var list = plus.webview.getWebviewById('new');
					//						list = mui.preload({
					//						id:'usercenter',
					//						url:'tab-personal-center.html'
					//					});
					//						
					//						//触发列表界面的自定义事件（refresh）,从而进行数据刷新
					//						mui.fire(list,'customEvent',{id:"sdf"});
					//						list.show('slide-in-right');
					//						//返回true，继续页面关闭逻辑
					//						return true;
					//				}
				});
			}(mui, document));
		</script>
	</body>

</html>